package com.yuandian.api.customer_perception.vo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

/**
 * 说明：高频告警vo对象
 * @Author yanjun
 * @Date 2021/5/10 8:47
 */
@Data
@HeadRowHeight(30)
public class HighFrequencyAlarmVo {

    /**
     * 序号
     */
    private Integer id;

    /**
     * 系统ID
     */
    @ExcelIgnore
    private Integer systemId;

    /**
     * 系统名称
     */
    private String systemName;

    /**
     * 业务编码
     */
    @ExcelIgnore
    private String businessCode;

    /**
     * 业务名称
     */
    private String businessName;

    /**
     * 告警量
     */
    private Integer alarmCount;

    /**
     * 告警返回码(故障类型)
     */
    private String alarmResultCode;

    /**
     * 告警指标id(告警类型)
     */
    @ExcelIgnore
    private Integer alarmIndicatorId;

    /**
     * 告警指标名称
     */
    private String alarmIndicatorName;

    /**
     * 统计类型
     */
    @ExcelIgnore
    private Integer statType;

    private String statValue;


    /**
     * 受理量
     */
    private Integer completeCount;



    /**
     * 失败率
     */
    private String failRate;

    @JsonIgnore
    @ExcelIgnore
    private Double failRateTmp;

    /**
     * 告警率
     */
    private String alarmRate;

    @JsonIgnore
    @ExcelIgnore
    private Double alarmRateTmp;


    /**
     * 最近发生时间
     */
    private String lastAlarmTime;

    /**
     * 最早发生时间
     */
    private String firstAlarmTime;

    /**
     * 告警值 预留
     */
    @ExcelIgnore
    private String alarmValue;

    /**
     * 告警描述
     */
    @ExcelIgnore
    private String alarmContext;

    /**
     * 建议
     */
    private String suggest;


    public void handleNumberFormat () {
        if (null != failRateTmp && failRateTmp.equals(100d)) {
            failRate = String.format("%.0f", failRateTmp);
        } else {
            failRate = String.format("%.2f", failRateTmp == null ? 0 : failRateTmp);
        }


        if (null != alarmRateTmp && alarmRateTmp.equals(100d)) {
            alarmRate = String.format("%.0f", alarmRateTmp);
        } else {
            alarmRate = String.format("%.2f", alarmRateTmp == null ? 0 : alarmRateTmp);
        }
    }
}
